Skip to content

feat(justfile): worktree-bootstrap to symlink .env.local from main#151

Merged
mikestankavich merged 1 commit into
mainfrom
feat/justfile-worktree-bootstrap
Jun 5, 2026
Merged

feat(justfile): worktree-bootstrap to symlink .env.local from main#151
mikestankavich merged 1 commit into
mainfrom
feat/justfile-worktree-bootstrap

Conversation

@mikestankavich

Copy link
Copy Markdown
Contributor

Add just worktree-bootstrap — symlink .env.local from main

Why

trakrf/infra worktrees don't carry the repo-root .env.local (gitignored, not copied by EnterWorktree). The worktree's committed .envrc does dotenv .env.local, but with no file present direnv loads nothing — so env-dependent recipes run with stale inherited shell env or fail outright:

  • tofu -chdir=terraform/gcp init → can't reach the R2 backend (no creds) → apply-root-app.sh <cluster> can't run.
  • just mosquitto-secrets → inherited MOSQUITTO_USER was stale (trakrf-ingester, pre-TRA-907) while the live broker user is trakrf-mqtt; running it would have regenerated the passwd under the wrong username and broken all broker auth in prod.

Surfaced while applying TRA-924 from a worktree. Mirrors platform's worktree-bootstrap pattern (which copies build artifacts); this one handles env.

What

A worktree-bootstrap recipe that symlinks .env.local from the main worktree:

  • Symlink, not copy → secret rotations in main propagate automatically.
  • No-op in the main worktree; errors clearly if main has no .env.local.
  • .env.local stays gitignored (never committed).

Verified

  • just --summary parses.
  • Ran it in a worktree: ✅ Linked .env.local from /home/mike/trakrf-infra; symlink resolves and carries the correct MOSQUITTO_USER=trakrf-mqtt.
  • git check-ignore .env.local → ignored.

Usage

just worktree-bootstrap   # then `direnv allow`

🤖 Generated with Claude Code

Worktrees don't carry the repo-root .env.local (gitignored, not copied by
EnterWorktree), so direnv loads nothing and env-dependent recipes (tofu/R2,
mosquitto-secrets, apply-root-app) fail or run with stale inherited values —
e.g. a stale MOSQUITTO_USER that would regenerate the broker passwd under the
wrong username. `just worktree-bootstrap` symlinks .env.local from the main
worktree (symlink, not copy, so rotations propagate). No-op in main; gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mikestankavich mikestankavich merged commit 7606069 into main Jun 5, 2026
19 checks passed
@mikestankavich mikestankavich deleted the feat/justfile-worktree-bootstrap branch June 5, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant